package com.rency.ues.webapp.resolver;

import javax.servlet.http.HttpServletRequest;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.servlet.handler.SimpleMappingExceptionResolver;

public class WebExceptionResolver extends SimpleMappingExceptionResolver {

	private static final Logger logger = LoggerFactory.getLogger(WebExceptionResolver.class);
	
	@Override
	protected String buildLogMessage(Exception ex, HttpServletRequest request) {
		String msg = String.format("页面解析异常, 解析路径[%s]", request.getRequestURI());
        logger.error(msg,ex);
        request.setAttribute("error", ex);
        return msg;
	}

	@Override
	protected void logException(Exception ex, HttpServletRequest request) {
		logger.error(buildLogMessage(ex, request), ex);
	}
	
}